package com.leyou.item.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.leyou.item.dto.BrandDTO;
import com.leyou.item.entitry.Brand;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author 张伟奇
 * @Date 2021/7/15 11:48
 * @description
 * @Version 1.0
 **/
@Component
public interface BrandMapper extends BaseMapper<Brand> {

    List<BrandDTO> findBrandByCategoryId(Long id);

    @Insert("insert into tb_category_brand (category_id,brand_id) values(#{categoryIds},#{brandId})")
    void  insertCategoryIdBrandId(@Param("categoryIds") Long categoryIds, @Param("brandId") Long brandId);

    @Delete("delete from tb_category_brand where brand_id=#{id}")
    void deleteCategoryIdBrandId(Long id);

    @Update("update  tb_brand set name=#{name},image=#{image},letter=#{letter} where id=#{id}")
    void  updateBrand(Brand brand);

    @Delete("delete from tb_category_brand where brand_id=#{id}")
    void deleteCategoryBrand(Long id);
}
